package sdu.acs.connections;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {

	private static String userName = "root";
	private static String password = "";
	private static String url = "jdbc:mysql://localhost/acs";

	private static Connection conn = null;

	/**
	 * Connects to MySql database
	 * 
	 * @return connection, if error return null
	 */

	public static Connection getConnection() {
		if (conn == null) {
			System.out.print("Connecting to Database... ");
			try {
				Class.forName("com.mysql.jdbc.Driver").newInstance();
				conn = DriverManager.getConnection(url, userName, password);
			} catch (Exception ex) {
				ex.printStackTrace();
				return null;
			}
		}
		return conn;
	}
}
